package com.dyzs.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;

import com.dyzs.activity.R;

public class CityUtil {
	  
	public static List<String> getAllCity(Context context,String proviceCode) {
		List list = new ArrayList<String>();
		String[] cityStr = context.getResources().getStringArray(R.array.city_names);
		String code = proviceCode.substring(0, 2);
		if (code.equals("11"))
			list.add("北京");// 北京
		else if (code.equals("12"))
			list.add("天津");// 天津
		else if (code.equals("31"))
			list.add("上海");// 上海
		else if (code.equals("50"))
			list.add("重庆");// 重庆
		else {
			for (int k = 0; k < cityStr.length; k++) {
				if (cityStr[k].startsWith(code)) {
					list.add(cityStr[k].split(",")[1]);
				}
			}
		}
		return list;
	}
	
	
	
	
	public static Map<String, String[]> getAllProvice(Context context) {
		String[] proviceStr = context.getResources().getStringArray(R.array.provice_names);
		String[] proviceCodes = new String[proviceStr.length];
		String[] proviceNames = new String[proviceStr.length];
		for (int k = 0; k < proviceStr.length; k++) {
			proviceNames[k] = proviceStr[k].split(",")[0];
			proviceCodes[k] = proviceStr[k].split(",")[1];
		}
		Map map = new HashMap<String, String[]>();
		map.put("proviceNames", proviceNames);
		map.put("proviceCodes", proviceCodes);
		return map;
	}
	
	public static Map<String, String[]> getProvice(Context context) {
		String[] proviceStr = context.getResources().getStringArray(R.array.provice_names);
		String[] proviceCodes = new String[proviceStr.length+1];
		String[] proviceNames = new String[proviceStr.length+1];
		proviceNames[0] = "省份";
		proviceCodes[0] = "000000";
		for (int k = 0; k < proviceStr.length; k++) {
			proviceNames[k+1] = proviceStr[k].split(",")[0];
			proviceCodes[k+1] = proviceStr[k].split(",")[1];
		}
		
		
		Map map = new HashMap<String, String[]>();
		map.put("proviceNames", proviceNames);
		map.put("proviceCodes", proviceCodes);
		return map;
	}
}
